INPUT	LD (LENLIN),A
	LD (AT_X),DE
	LD (BUF_IN),HL
	LD (BEG_BI),HL
	PUSH HL
	LD DE,BUFCOP
	LD C,A
	XOR A
	LD B,A
	PUSH BC
	LDIR
	POP BC
	DEC C
	POP HL
	PUSH HL
	POP DE
	INC DE
	LD (HL),32
	LDIR
	LD (TEKLEN),A
	CALL SETCUR
INPUT2	XOR A
	LD (23560),A
	LD A,(23560)
	OR A
	JR Z,INPUT2
	CALL BEEP
	JR NC,INPUT1
	CP
	JR NZ,INPUT9
	CALL RETNAM
	RET
INPUT9	CP
	JR Z,INPUT3
	CP
	JR Z,INPUT4
	CP
	JR Z,INPUT5
	CP
	JR Z,INPUT6
	CP
	JR Z,INPUT7
	CP
	JR NZ,INPUT8
	CALL RETNAM
	JR INPUT2
INPUT8	CP
	RET Z
	JR INPUT2
INPUT1	CP 128
	JR NC,INPUT2
INPUT7	LD B,A
	CALL ENDLIN
	JR NC,INPUT2
	INC A
	LD (TEKLEN),A
	LD A,B
	LD HL,(BUF_IN)
	LD (HL),A
	INC HL
	LD (BUF_IN),HL
	CALL RESCUR
	LD DE,(AT_X)
	CP 3
	JR NZ,INPUT10
	LD HL,ADMASK
	JR INPUT11
INPUT10	CALL CHARAD
INPUT11	PUSH HL
	CALL BEGADD
	POP DE
	EX DE,HL
	CALL PRCHAR
	CALL NEXPOS
	CALL SETCUR
	JR INPUT2
INPUT3	LD A,(TEKLEN)
	OR A
	JR Z,INPUT2
	CALL LENRIG
	PUSH BC
	PUSH BC
	LD HL,(BUF_IN)
	PUSH HL
	PUSH HL
	POP DE
	DEC DE
	LDIR
	POP HL
	POP BC
	DEC C
	ADD HL,BC
	LD (HL),32
	CALL RESCUR
	CALL PREPOS
	LD HL,(BUF_IN)
	DEC HL
	LD (BUF_IN),HL
	POP BC
	LD C,B
	LD (TIMBYT),DE
	CALL PRLINE
	LD DE,(TIMBYT)
	LD (AT_X),DE
	CALL SETCUR
	JP INPUT2
INPUT4	CALL ENDLIN
	JP Z,INPUT2
	CALL LENRIG
	DEC C
	PUSH BC
	LD HL,(BUF_IN)
	PUSH HL
	PUSH HL
	POP DE
	INC DE
	LDIR
	POP HL
	LD (HL),32
	POP BC
	LD B,C
	LD DE,(AT_X)
	CALL PRLINE
	JP INPUT2
INPUT5 LD A,(TEKLEN)
	OR A
	JP Z,INPUT2
	CALL RESCUR
	CALL PREPOS
	LD HL,TEKLEN
	DEC (HL)
	LD HL,(BUF_IN)
	DEC HL
	LD (BUF_IN),HL
	CALL SETCUR
	JP INPUT2
INPUT6	CALL ENDLIN
	JP Z,INPUT2
	CALL RESCUR
	CALL NEXPOS
	LD HL,TEKLEN
	INC (HL)
	LD HL,(BUF_IN)
	INC HL
	LD (BUF_IN),HL
	CALL SETCUR
	JP INPUT2
SETCUR	LD DE,(AT_X)
	CALL ADDATT
	SET 7,(HL)
	RET
RETNAM	CALL RESCUR
	LD DE,(BEG_BI)
	PUSH DE
	LD HL,BUFCOP
	LD A,(LENLIN)
	LD (TEKLEN),A
	PUSH AF
	LD C,A
	LD B,0
	LDIR
	LD (BUF_IN),DE
	POP BC
	POP HL
	CALL PRLINE
	CALL SETCUR
	RET
RESCUR	LD DE,(AT_X)
	CALL ADDATT
	RES 7,(HL)
	RET
PRLINE	PUSH BC
	LD A,(HL)
	PUSH HL
	CP 1
	JR NZ,PRLIN1
	LD HL,ADDEL
	JR PRLIN2
PRLIN1	CP 3
	JR NZ,PRLINN3
	LD HL,ADMASK
	JR PRLINN4
PRLIN3	CALL CHARAD
PRLIN4	PUSH HL
	LD DE,(AT_X)
	CALL BEGADD
	POP DE
	EX DE,HL
	CALL PRCHAR
	CALL NEXPOS
	POP HL
	INC HL
	POP BC
	DJNZ PRLINE
	RET
NEXPOS	 LD DE,(AT_X)
	INC E
	LD A,E
	CP 32
	JR C,NEXPOS1
	INC D
	LD E,0
NEXPOS1	LD (AT_X),DE
	RET
ENDLIN	LD A,(TEKLEN)
	LD HL,LENLIN
	CP (HL)
	RET
LENRIG	LD A,(TEKLEN)
	LD B,A
	LD A,(LENLIN)
	SUB B
	INC A
	LD C,A
	LD B,0
	RET
PREPOS	LD DE,(AT_X)
	DEC E
	JR NC,PREPOS1
	DEC D
	LD E,31
PREPOS1	LD (AT_X),DE
	RET
